package com.jsh.erp.constants;

import lombok.Getter;

import java.util.stream.Stream;

//0待兑现 1已兑现 2跳票
@Getter
public enum ChequeEnum {

    UNREALIZED(0, "待兑现", "PDC Cheque"),
    REALIZED(1, "已兑现", "Realized"),
    RETURN(2, "跳票", "Cheque Return"),

    ;

    private int status;
    private String name;
    private String enName;


    ChequeEnum(int status, String name, String enName) {
        this.status = status;
        this.name = name;
        this.enName = enName;
    }

    public static String getNameByStatus(int status, boolean isEn) {
        if (isEn) {
            return Stream.of(ChequeEnum.values())
                    .filter(chequeEnum -> chequeEnum.status == status)
                    .map(ChequeEnum::getEnName)
                    .findFirst()
                    .orElse(null);
        } else {
            return Stream.of(ChequeEnum.values())
                    .filter(chequeEnum -> chequeEnum.status == status)
                    .map(ChequeEnum::getName)
                    .findFirst()
                    .orElse(null);
        }
    }
}
